<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            padding:0;
            margin:0;
        }
        #root button{
            padding:5px;
            margin:5px;
        }
        #root button.active{
            background: red;
        }
        #root div{
            width: 500px;
            height: 300px;
            border:1px solid green;
        }
    </style>
</head>
<body>
    <div id="root">
        <button>娱乐</button>
        <button>财经</button>
        <button>体育</button>
        <div>娱乐新闻列表</div>
        <div>财经新闻列表</div>
        <div>体育新闻列表</div>
    </div>
</body>
<script>
    const root = document.querySelector("#root");
    const btns = root.querySelectorAll("#root button");
    const divs = root.querySelectorAll("#root div");

    let activeIndex = 0;// 选中的下标

    btns.forEach(function(btn,index){
        divs[index].style.display = "none";
        btn.onclick = function(){
            if(index === activeIndex) return;
            btns[activeIndex].className = null;
            divs[activeIndex].style.display = "none";
            activeIndex = index;
            show();
        }
    })
    show();
    function show(){
        btns[activeIndex].className = "active";
        divs[activeIndex].style.display = "block";
    }
</script>
</html>